package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Patentauthor;
import com.hbnu.system.service.IPatentauthorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/patentauthor")
@Api(tags = "专利的作者管理")
public class PatentauthorController {

    @Autowired
    IPatentauthorService iPatentauthorService;

    @ApiOperation("新增专利作者")
    @PostMapping("/addPatentAuthor")
    public Rest<String> addPatentAuthor(@RequestBody Patentauthor patentauthor){
        boolean ba = iPatentauthorService.addPatentAuthor(patentauthor);
        return ba ? Rest.success() : Rest.failed();
    }

    @ApiOperation("删除专利作者信息")
    @GetMapping("/deletePatentAuthor")
    public Rest<String> deletePatentAuthor(String id){
        boolean ba1 = iPatentauthorService.deletePatentAuthor(id);
        return ba1 ? Rest.success():Rest.failed();
    }

    @ApiOperation("修改专利作者信息")
    @PostMapping("/updatePatentAuthor")
    public Rest<String> updatePatentAuthor(@RequestBody Patentauthor patentauthor){
        boolean ba2 = iPatentauthorService.updatePatentAuthor(patentauthor);
        return ba2 ? Rest.success():Rest.failed();
    }

    @ApiOperation("根据专利编号搜索作者信息")
    @GetMapping("/selectAllAuthor")
    public Rest<List<Patentauthor>> selectAllAuthor(String id){
        List<Patentauthor> list = iPatentauthorService.listAuthor(id);
        return Rest.success(list,list.size());
    }

    @ApiOperation("校级管理员修改作者系数")
    @PostMapping("/upPatentAuthor")
    public Rest<Boolean> upPatentAuthor(@RequestBody Patentauthor patentAuthor){
        boolean update = iPatentauthorService.upPatentAuthor(patentAuthor);
        return update ? Rest.success() : Rest.failed();
    }

}

